package com.example.zhangguoqing.homeofpet.data;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.zhangguoqing.homeofpet.R;
import com.example.zhangguoqing.homeofpet.Tip.Bean;

import java.util.ArrayList;
import java.util.HashMap;

public class ListViewAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<HashMap<String,Object>>data;
    databean databean=null;
    public ListViewAdapter(Context context,ArrayList<HashMap<String,Object>>data){
        this.context=context;
        this.data=data;
    }
    @Override


    public int getCount() {
        return 3;
    }

    @Override
    public Object getItem(int position) {
        return data.get( position );
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View holder, ViewGroup parent) {
        if (holder==null){
            databean=new databean();
            LayoutInflater layoutInflater=LayoutInflater.from( context );
            holder=layoutInflater.inflate( R.layout.listitem_data,null );
            databean.textView5=(TextView)holder.findViewById( R.id.textView5 );
            databean.textView7=(TextView)holder.findViewById( R.id.textView7 );
            holder.setTag( databean );
        }else {
            databean = (databean) holder.getTag();
        }
            databean.textView5.setText( (String)data.get( position ).get( "property" ) );
            databean.textView7.setText( (String)data.get( position ).get( "num" ) );
            return holder;
        }
    }

